﻿@model IEnumerable<viBook.Models.Category>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
<table>
    <tr>
        <th>
            CategoryName
        </th>
        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.CategoryName)
        </td>
        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
            @Html.ActionLink("Details", "Details", new { id=item.Id }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.Id })
        </td>
    </tr>
}

 <div id="content">hello</div>
 <script src="https://www.google.com/jsapi?key=ABQIAAAAHnrv40LDgOtv4rSQy1b8fRTLVLcwd-KOtl51WFBxK6nY0KXPzhQz4hZL4epP2u4jnJh73v4hV_6pIw"></script>
    <script type="text/javascript">

        google.load("language", "1");

        function initialize() {
            var content = document.getElementById('content');
            // Setting the text in the div.
            content.innerHTML = '<div id="text">Hola, me alegro mucho de verte.<\/div><div id="translation"/>';

            // Grabbing the text to translate
            var text = document.getElementById("text").innerHTML;

            // Translate from Spanish to English, and have the callback of the request
            // put the resulting translation in the "translation" div.
            // Note: by putting in an empty string for the source language ('es') then the translation
            // will auto-detect the source language.
            google.language.translate(text, 'es', 'en', function (result) {
                var translated = document.getElementById("translation");
                if (result.translation) {
                    translated.innerHTML = result.translation;
                }
            });
        }
        google.setOnLoadCallback(initialize);
    
    </script>